#include <stdio.h>

void reduce(int numerator, int denominator,
            int *reduced_numerator, int *reduced_denominator);

int main(void)
{
    int numerator, denominator, a, b;

    printf("Enter a fraction: ");
    scanf("%d/%d", &numerator, &denominator);

    reduce(numerator, denominator, &a, &b);

    printf("In lowest terms: %d/%d", a, b);

    return 0;
}

void reduce(int numerator, int denominator, 
            int *reduced_numerator, int *reduced_denominator)
{
    int temp,
        m = numerator,
        n = denominator;

    while (n != 0)
    {
        temp = m % n;
        m = n;
        n = temp;
    }

    *reduced_denominator = denominator / m;
    *reduced_numerator = numerator / m;
}




